package com.letv.core.network.volley;

import com.letv.core.bean.DataHull;
import com.letv.core.bean.LetvBaseBean;
import com.letv.core.network.volley.VolleyResponse.CacheResponseState;
import com.letv.core.network.volley.VolleyResponse.NetworkResponseState;

/**
 * 请求返回值(同步请求时候使用)
 * 
 * @author zhuqiao
 *
 */
public class VolleyResult<T extends LetvBaseBean> {
    public final T result;
    public final DataHull dataHull;
    /**
     * 请求网络状态
     */
    public final NetworkResponseState networkState;
    /**
     * 请求缓存状态
     */
    public final CacheResponseState cacheState;
    /**
     * 错误信息.如果不为空,那么需要上传
     */
    public final String errorInfo;

    public VolleyResult(T result, DataHull dataHull, NetworkResponseState networkState, CacheResponseState cacheState,
            String errorInfo) {
        this.result = result;
        this.dataHull = dataHull;
        this.networkState = networkState;
        this.cacheState = cacheState;
        this.errorInfo = errorInfo;
    }

    /**
     * 网络请求返回值
     * 
     * @author zhuqiao
     *
     * @param <T>
     */
    static class VolleyNetworkResult<T extends LetvBaseBean> extends VolleyResult<T> {

        public VolleyNetworkResult(T result, DataHull dataHull, NetworkResponseState state) {
            super(result, dataHull, state, CacheResponseState.IGNORE, "");
        }

        public VolleyNetworkResult(T result, DataHull dataHull, NetworkResponseState state, String errorInfo) {
            super(result, dataHull, state, CacheResponseState.IGNORE, errorInfo);
        }

    }

    /**
     * 缓存请求返回值
     * 
     * @author zhuqiao
     *
     * @param <T>
     */
    static class VolleyCacheResult<T extends LetvBaseBean> extends VolleyResult<T> {

        public VolleyCacheResult(T result, DataHull dataHull, CacheResponseState state) {
            super(result, dataHull, NetworkResponseState.IGNORE, state, "");
        }

        public VolleyCacheResult(T result, DataHull dataHull, CacheResponseState state, String errorInfo) {
            super(result, dataHull, NetworkResponseState.IGNORE, state, errorInfo);
        }
    }

}
